# -*- coding: utf-8 -*-
# -----------------------
# @Time ： 2021/6/23 11:13 上午
# @Author ： liyi03
# @File ：keyWordAction.py
# @IDE ：PyCharm

from public.wdaClient import wda_client


class KeyWord(object):
    c = wda_client

######################## 执行动作 ###############################
    def click_(self, key_: str):
        getattr(self, key_).click()

    def exists_(self, key_: str):
        return getattr(self,key_).exists

    def send_(self, key_: str,data: str):
        self.click_(key_)
        try:
            getattr(self, key_).clear_text()
        except:
            pass
        finally:
            self.c.send_keys(data)

    def get_text(self, key_: str):
        """
        获取元素属性文本内容
        :param key_:
        :return:
        """
        return getattr(self, key_).get().value



######################## 元素定位方式 ############################
    def class_name(self, element: str):
        self.class_name_ = self.c(className=element)
        return self

    def value(self, element: str):
        self.value_ = self.c(value=element)
        return self

    def lable(self, element: str):
        self.lable_ = self.c(label=element)
        return self

    def name(self, element: str):
        self.name_ = self.c(name=element)
        return self

    def id(self, element: str):
        self.id_ = self.c(id=element)
        return self

    def xpath(self, element: str):
        self.xpath_ = self.c(xpath=element)
        return self

    def combines(self):
        # 组合搜索
        pass


if __name__ == '__main__':
    KeyWord().value('用药建议').click_('value_')
    # KeyWord().value('用药建议').click()
    # key_action = {
    #     "value":{"find_elment_value":"用药建议","action":"click_"},
    #     "lable":{"find_elment_value":"用药建议","action":"click_"},
    # }
